﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEditor.AI;

public class MapUIPanel : MonoBehaviour{

    private float minFactor = 2;
    private float maxFactor = 4;

    private float m_scale = 2f;
    private Transform m_Map;
    private float m_offset = 0.02f;
    private CanvasGroup m_canvasGroup;

    void Start() {
        m_Map = transform.Find( "functionPanel/shaderMap/Map" );
        m_Map.GetComponent<RectTransform>().localScale = Vector3.one * m_scale;
        m_canvasGroup = transform.parent.GetComponent<CanvasGroup>();
    }

    private void Update() {
        if (m_canvasGroup.alpha == 0)
            return;
        //地图放大
        if (Input.GetAxis( "Mouse ScrollWheel" ) > m_offset) {
            m_scale += m_offset*2f;
            if (m_scale >maxFactor)
            {
                m_scale = maxFactor;
            }
            m_Map.GetComponent<RectTransform>().localScale = Vector3.one * m_scale;
        }
        else if (Input.GetAxis( "Mouse ScrollWheel" ) < -m_offset) {
            m_scale -= m_offset*2f;
            if (m_scale<=minFactor)
            {
                m_scale = minFactor;
            }
            m_Map.GetComponent<RectTransform>().localScale = Vector3.one * m_scale;
        }
    }
    private void ShowShipsInMap() {

    }
    
}

